package tunafish2k.rpgex.entities;

import org.jetbrains.annotations.Nullable;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.PersistentProjectileEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.world.World;
import tunafish2k.rpgex.registries.ItemRegistry;

public class StoneDartProjectile extends PersistentProjectileEntity {
    public StoneDartProjectile(EntityType<? extends PersistentProjectileEntity> entityType, World world) {
        super(entityType, world);
        this.pickupType = net.minecraft.entity.projectile.PersistentProjectileEntity.PickupPermission.ALLOWED;
    }

    public StoneDartProjectile(EntityType<? extends PersistentProjectileEntity> type, double x, double y, double z,
            World world, ItemStack stack, @Nullable ItemStack weapon) {
        super(type, x, y, z, world, stack, weapon);
        this.pickupType = net.minecraft.entity.projectile.PersistentProjectileEntity.PickupPermission.ALLOWED;
    }

    public StoneDartProjectile(EntityType<? extends PersistentProjectileEntity> type, LivingEntity owner, World world,
            ItemStack stack, @Nullable ItemStack shotFrom) {
        super(type, owner, world, stack, shotFrom);
        this.pickupType = net.minecraft.entity.projectile.PersistentProjectileEntity.PickupPermission.ALLOWED;
    }

    @Override
    protected ItemStack getDefaultItemStack() {
        return new ItemStack(ItemRegistry.STONE_DART);
    }

    @Override
    protected void onEntityHit(EntityHitResult entityHitResult) {
        Entity entity = entityHitResult.getEntity();
        entity.damage(this.getDamageSources().arrow(this, this.getOwner()), 5.0f);
        this.kill();
    }
}
